﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CommonsLib.ORM
{
    [Serializable]
    public class DataFieldAttribute : Attribute
    {
        private string _FieldName;
        private string _FieldType;
        private int _length;
        private bool _IsIdentity;

        public DataFieldAttribute(string fieldname, string fieldtype, bool isidentity, int length)
        {
            this._FieldName = fieldname;
            this._FieldType = fieldtype;
            this._length = length;
            this._IsIdentity = isidentity;
        }

        /// <summary>
        /// 作用与字段的时候调用的构造函数
        /// </summary>
        /// <param name="fieldname">字段名</param>
        /// <param name="isidentity">IDentity字段</param>
        /// <param name="length">字段长度</param>        
        public DataFieldAttribute(string fieldname, bool isidentity, int length)
            : this(fieldname, "", isidentity, length)
        { }

        /// <summary>
        /// 作用与字段的时候调用的构造函数
        /// </summary>
        /// <param name="fieldname">字段名</param>
        /// <param name="isidentity">此字段是否Identity字段</param>
        public DataFieldAttribute(string fieldname, bool isidentity)
            : this(fieldname, isidentity, 0)
        { }

        /// <summary>
        /// 作用与字段的时候调用的构造函数
        /// </summary>
        /// <param name="fieldname">字段名</param>
        public DataFieldAttribute(string fieldname)
            : this(fieldname, false)
        { }

        public DataFieldAttribute(string fieldname, string fieldtype)
            : this(fieldname, fieldtype, false, 0)
        { }
        public DataFieldAttribute(string fieldname, string fieldtype, int lenght)
            : this(fieldname, fieldtype, false, lenght)
        { }
        /// <summary>
        /// 字段名
        /// </summary>
        public string FieldName
        {
            get { return this._FieldName; }
        }

        /// <summary>
        /// 字段类型
        /// </summary>
        public string FieldType
        {
            get { return this._FieldType; }
            set { this._FieldType = value; }
        }

        /// <summary>
        /// 字段长度
        /// </summary>
        public int length
        {
            get { return this._length; }
        }

        /// <summary>
        /// 是否IDENTITY字段
        /// </summary>
        public bool IsIdentity
        {
            get { return this._IsIdentity; }
        }
    }
}
